package com.itany.book.service.impl;

import com.itany.exception.UsernameAndPasswordErrorException;
import com.itany.mapper.ManagerUserMapper;
import com.itany.pojo.ManagerUser;
import com.itany.service.ManagerUserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Throwable.class)

public class ManagerUserServiceImpl implements ManagerUserService {
    @Resource
    private ManagerUserMapper managerUserMapper;

    public ManagerUser login(ManagerUser managerUser) throws UsernameAndPasswordErrorException {
        ManagerUser result= managerUserMapper.selectByUsernameAndPassword(managerUser);
        if (null==result){
            throw new UsernameAndPasswordErrorException("用户名或者密码错误");
        }
        return result;
    }
}
